// pages/my/balance/balance.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isFirst: '1',
    sexSets: [{
      value: '男',
      checked: 'true'
    }, {
      value: '女',
      checked: 'false'
    }, {
      value: '保密',
      checked: 'false'
    }],
    birthdaystr: '1990-01-01',
    birth: {
      year: '1990',
      month: '01',
      day: '01'
    },
    isAgree: '1',
    isAgree2: '1',
    rctype: '1',
    sum: '200',
    isPassword: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  radioChange: function (e) {

  },
  bindDateChange: function (e) {
    var dateval = e.detail.value;
    console.log(dateval);
    var vals = dateval.split('-');
    var birth = this.data.birth;
    birth.year = vals[0];
    birth.month = vals[1];
    birth.day = vals[2];
    this.setData({
      birthdaystr: dateval,
      birth: birth
    });
  },
  setIsDefault: function () {
    var isAgree = this.data.isAgree;
    if (isAgree == '1') {
      isAgree = '0';
    }
    else {
      isAgree = '1';
    }
    this.setData({ isAgree: isAgree });
  },
  setIsDefault2:function(){
    var isAgree2 = this.data.isAgree2;
    if (isAgree2 == '1') {
      isAgree2 = '0';
    }
    else {
      isAgree2 = '1';
    }
    this.setData({ isAgree2: isAgree2 });
  },
  changeRechageType:function(e){
    var rctype = e.currentTarget.id;
    if(rctype == this.data.rctype){
      return;
    }
    this.setData({
      rctype: rctype
    });
  },
  infoSubmit:function(){
    this.setData({
      isFirst: '0'
    });
  },
  changeSum:function(e){
    var sum = e.currentTarget.id;
    if(sum == this.data.sum){
      return;
    }
    this.setData({
      sum: sum
    });
  },
  changeEyeOpen:function(){
    var isPassword = this.data.isPassword;
    if (isPassword == true) {
      isPassword = false;
    }
    else {
      isPassword = true;
    }
    this.setData({ isPassword: isPassword });
  },
  scanCard:function(){
    wx.scanCode({
      success:function(res){
        console.log(res);
      }
    });
  },
  backToOnlineRecharge:function(){
    this.setData({
      rctype: '1'
    });
  },
  checkMoneyDetail:function(){
    wx.redirectTo({
      url: './moneydetail/moneydetail',
    });
  },
  setMoneyPwd:function(){
    wx.redirectTo({
      url: './password/password?target=set',
    });
  }
})